/**
*   \file   AABB.h
*   \author Dave Reid
*   \brief  Header file for the AABB shape.
*/
#ifndef __EAGL_AABB_H_
#define __EAGL_AABB_H_

namespace eagl
{

/**
*   \brief  Class representing an AABB.
*
*   An AABB is an Axis-Aligned Bounding Box. It's only properties are it's extents and position.
*   These AABB's are represented as centre-radius boxes.
*/
class AABB
{
public:

    /**
    *   \brief  Default constructor.
    */
    AABB() : m_extents(1.0f, 1.0f, 1.0f)
    {
    }

    /**
    *   \brief  Copy constructor.
    */
    AABB(const AABB &aabb) : m_extents(aabb.getExtents()), m_position(aabb.getPosition())
    {
    }

    /**
    *   \brief               Constructor.
    *   \param  extents [in] The extents of the AABB.
    *   \param  pos     [in] The position of the AABB.
    */
    AABB(const vec3 &extents, const vec3 &pos) : m_extents(extents), m_position(pos)
    {
    }


    /**
    *   \brief  Retrieves the extents of the Box.
    *   \return The extents of the Box.
    */
    const vec3 & getExtents() const
    {
        return this->m_extents;
    }

    /**
    *   \brief               Sets the extents of the Box.
    *   \param  extents [in] The extents of the Box.
    */
    void setExtents(const vec3 &extents)
    {
        this->m_extents = extents;
    }

    /**
    *   \brief              Sets the extents of the Box.
    *   \param  width  [in] The new width of the Box.
    *   \param  height [in] The new height of the Box.
    *   \param  depth  [in] The new depth of the Box.
    */
    void setExtents(float width, float height, float depth)
    {
        this->m_extents.x = width;
        this->m_extents.y = height;
        this->m_extents.z = depth;
    }

    /**
    *   \brief  Retrieves the position of the AABB.
    *   \return The position of the AABB.
    */
    const vec3 & getPosition() const
    {
        return this->m_position;
    }

    /**
    *   \brief          Sets the position of the AABB.
    *   \param pos [in] The new position of the AABB.
    */
    void setPosition(const vec3 &pos)
    {
        this->m_position = pos;
    }

    /**
    *   \brief  Retrieves the minimum size of each dimension.
    *   \return The smallest positions of each dimension.
    */
    vec3 getMin() const
    {
        return this->m_position - this->m_extents;
    }

    /**
    *   \brief  Retrieves the maximum size of each dimension.
    *   \return The largest positions of each dimension.
    */
    vec3 getMax() const
    {
        return this->m_position + this->m_extents;
    }


private:

    /// The extents of the AABB.
    vec3 m_extents;

    /// The position of the AABB.
    vec3 m_position;

};

}

#endif  // __EAGL_AABB_H_